@extends('admin.main')

@section('content')
<div class="wrapper wrapper-content">
    <div class="m-b">
        <a href="javascript:;" class="btn btn-default" onclick="history.back();"><i class="fa fa-angle-double-left"></i> 返回列表</a>
    </div>
    <div class="ibox">
        <div class="ibox-title">
            <h5>编辑设计师</h5>
        </div>
        <div class="ibox-content">
            <form id="formEdit" method="post" class="form-horizontal">
                <div class="form-group">
                    <label class="col-sm-2 control-label">姓名</label>
                    <div class="col-sm-5">
                        <input type="text" name="realname" value="{{$designer->realname}}" class="form-control" required="" autofocus />
                    </div>
                    <div class="col-sm-5">
                        <label class="radio-inline i-checks">
                            <input type="radio" name="sex" value="男"{{ $designer->sex == '男' ? ' checked=""' : '' }} />
                            男
                        </label>
                        <label class="radio-inline i-checks">
                            <input type="radio" name="sex" value="女"{{ $designer->sex == '女' ? ' checked=""' : '' }} />
                            女
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">职位</label>
                    <div class="col-sm-2">
                        <select name="post" class="form-control">
                            @foreach($posts as $val)
                            <option value="{{$val}}"{{ $designer->post == $val ? ' selected' : '' }}>{{$val}}</option>
                            @endforeach
                        </select>
                    </div>
                    <label class="col-sm-1 control-label">工作经验</label>
                    <div class="col-sm-2">
                        <select name="experience" class="form-control">
                            @foreach($experiences as $val)
                            <option value="{{$val}}"{{ $designer->experience == $val ? ' selected' : '' }}>{{$val}}</option>
                            @endforeach
                        </select>
                    </div>
                    <label class="col-sm-1 control-label">收费标准</label>
                    <div class="col-sm-2">
                        <select name="cost" class="form-control">
                            @foreach($costs as $val)
                            <option value="{{$val}}"{{ $designer->cost == $val ? ' selected' : '' }}>{{$val}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">擅长</label>
                    <div class="col-sm-10">
                        @foreach($styles as $val)
                        <label class="checkbox-inline i-checks">
                            @if (in_array($val, explode(',', $designer->goodat)))
                            <input type="checkbox" name="goodat[]" value="{{$val}}" checked="" />
                            @else
                            <input type="checkbox" name="goodat[]" value="{{$val}}" />
                            @endif
                            {{$val}}
                        </label>
                        @endforeach
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">个人简介</label>
                    <div class="col-sm-10">
                        <textarea name="resume" class="form-control">{{$designer->resume}}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">主要作品</label>
                    <div class="col-sm-10">
                        <textarea name="works" class="form-control">{{$designer->works}}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">设计理念</label>
                    <div class="col-sm-10">
                        <textarea name="idea" class="form-control">{{$designer->idea}}</textarea>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">人气指数</label>
                    <div class="col-sm-2">
                        <input type="text" name="fans" class="form-control" value="{{$designer->fans}}" />
                    </div>
                    <label class="col-sm-1 control-label">委托数量</label>
                    <div class="col-sm-2">
                        <input type="text" name="trusts" class="form-control" value="{{$designer->trusts}}" />
                    </div>
                    <label class="col-sm-1 control-label">浏览次数</label>
                    <div class="col-sm-2">
                        <input type="text" name="views" class="form-control" value="{{$designer->views}}" />
                    </div>
                    <div class="col-sm-2">
                        <label class="checkbox-inline i-checks">
                            <input type="checkbox" name="status" value="1" {{ $designer->status == 1 ? ' checked' : '' }} />
                            审核
                        </label>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-2">
                        <input type="hidden" name="id" value="{{$designer->id}}" />
                        <button class="btn btn-warning btn-w-m" type="submit">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection

@section('pageheader')
    <link href="/assets/iCheck/custom.css" rel="stylesheet">
@endsection

@section('pagescript')
<script src="/assets/iCheck/icheck.min.js"></script>
<script>
    $("#side-menu li[rel='team']").addClass("active")
        .parents("ul").addClass("in").parents("li").addClass("active");

    $('.i-checks').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
    });

    $("#formEdit").on("submit", function(){
        this.status.value = this.status.checked ? 1 : 0;
        this.status.checked = true;
        var formdata = $(this).serialize();
        $.post("{{url('admin/team/designer-update')}}", formdata, function(){
            window.location.href = document.referrer;
        }).fail(failure);
        return false;
    });
</script>
@endsection
